<?php

namespace App\Containers\AppSection\Confirmation\Actions;

use App\Containers\AppSection\Confirmation\Models\Confirmation;
use App\Containers\AppSection\Confirmation\Tasks\FindConfirmationByCodeTask;
use App\Containers\AppSection\Confirmation\UI\API\Requests\CheckProfilePhoneCodeRequest;
use App\Ship\Parents\Actions\Action;

class CheckProfilePhoneCodeAction extends Action
{
    public function run(CheckProfilePhoneCodeRequest $request): ?Confirmation
    {
        return app(FindConfirmationByCodeTask::class)->run(
            $request->getInputByKey('code'), $request->profile()->phone,
            $request->getInputByKey('type'),
            config('appSection-confirmation.confirms.phone.type')
        );
    }
}
